<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="generator" content="ScreenSteps http://www.screensteps.com/" />
	<title>Adding and working with nKnightControls</title>
	<link href="../css/modern.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8" />
	<link href="../css/prettyPhoto.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8" />
	<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
  <script type="text/javascript" charset="utf-8">
		$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({
			  show_title: false
			});
		});
  </script>
</head>

<body class="trebuchet">
	<div id="wrapper">		
		<div id="LessonContent">
			<div class="LessonHeader">
			  <p><a href="../nKnight.html">Back to Table of Contents</a></p>
				<h1 class="LessonTitle">Adding and working with nKnightControls</h1>
			</div>
			
			
				<div id="step_1" class="lessonStep top">
	    
		 <p>All nKnight controls have one very significant event: oError. If a user doesn't have access to a resource then nKnight will generate this event. For an example if a button is used and the user has access to the button, on clicking the button Button Click event shall be activated, otherwise it will activate the oError event.</p>
	</div>
	<div class="clear"></div>
	<div id="step_2" class="lessonStep top">
	        <h2 class="StepTitle">1. nKnightbutton: </h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/1._nKnightbutton.png" width="98" height="30" alt="" />
</div> <p spacebelow="10">Access to this button will be validated when user click it, so you have to write the following,<br />
<font color="#C00000">private void nKnightButton1_Click(object sender, EventArgs e)</font><br />
<font color="#C00000">{</font><br />
<font color="#C00000">    try</font><br />
<font color="#C00000">      {</font><br />
          <font color="#00B050">//Success, user have access to do this operation</font><br />
      <font color="#C00000">}</font><br />
<font color="#C00000">    catch (Exception ex)</font><br />
<font color="#C00000">      {</font></p>
<p firstindent="36">    <br />
<font color="#C00000">      }</font></p>
<p spacebelow="10"><font color="#C00000">}</font></p>
<p spacebelow="10">If you want to get the error message then you have to get it like,<br />
<font color="#C00000">private void nKnightButton1_oError(nKnight.RBACControl.ControlEventArgs e)</font><br />
<font color="#C00000">{</font><br />
<font color="#C00000">     MessageBox.Show(e.ErrorMessage);</font></p>
<p spacebelow="10"><font color="#C00000">}</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_3" class="lessonStep top">
	        <h2 class="StepTitle">2. nKnightCheckBox:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/checkbox.png" width="122" height="24" alt="" />
</div> <p>Access to this button will be validated when user click to check/ uncheck it, so the coding is same as nKnightButton.</p>
	</div>
	<div class="clear"></div>
	<div id="step_4" class="lessonStep top">
	        <h2 class="StepTitle">3. nKnightCheckListBox:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/checkboxList.png" width="125" height="101" alt="" />
</div> <p>Access to this listbox will be validated when user will check/ uncheck any item in the listview. So the coding will be same but event will be </p>


<p><font color="#C00000">private void nKnightCheckListBox1_ItemCheck(object sender, ItemCheckEventArgs e).</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_5" class="lessonStep top">
	        <h2 class="StepTitle">4. nKnightComboBox:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/combobox.png" width="123" height="25" alt="" />
</div> <p>Access to this combobox will be validated when user change any selection in the combobox. So the event will be,</p>


<p><font color="#C00000">private void nKnightCombo1_SelectionChangeCommitted(object sender, EventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_6" class="lessonStep top">
	        <h2 class="StepTitle">5. nKnightDateTimePicker:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/dtp.png" width="204" height="25" alt="" />
</div> <p>Access to this control will be validated when user leave the control. So the event is,</p>


<p><font color="#C00000">private void nKnightDateTimePicker1_Validating(object sender, CancelEventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_7" class="lessonStep top">
	        <h2 class="StepTitle">6. nKnightGridView:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/dgv.png" width="272" height="93" alt="" />
</div> <p>Access to this control will be validated when user will try to change something in the cell. So the event will be,</p>


<p><font color="#C00000">private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_8" class="lessonStep top">
	        <h2 class="StepTitle">7. nKnightLinkLabel:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/linklabel.png" width="99" height="24" alt="" />
</div> <p>Access to this control will be validated, when user click it. So the event will be, </p>


<p><font color="#C00000">private void nKnightLinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_9" class="lessonStep top">
	        <h2 class="StepTitle">8. nKnightMaskedTextBox:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/mask.png" width="104" height="25" alt="" />
</div> <p>Access to this control will be validated when user try to write something. So the event will be,</p>


<p><font color="#C00000">private void nKnightMaskedTextBox1_KeyPress(object sender, KeyPressEventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_10" class="lessonStep top">
	        <h2 class="StepTitle">9. nKnightRadioButton:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/radio.png" width="132" height="22" alt="" />
</div> <p>Access to this control will be validated when user try to check/ uncehck it. So the event is,</p>


<p><font color="#C00000">private void nKnightRadioButton1_KeyPress(object sender, KeyPressEventArgs e)</font></p>
	</div>
	<div class="clear"></div>
	<div id="step_11" class="lessonStep top">
	        <h2 class="StepTitle">10. nKnightTextBox:</h2>
		<div class="image">
<img src="images/Adding_and_working_with_nKnightControls/textbox.png" width="101" height="25" alt="" />
</div> <p>Access to this control will be validated when user will try to write something. So the event is,</p>


<p><font color="#C00000">private void nKnightTextBox1_KeyPress(object sender, KeyPressEventArgs e) </font></p>
	</div>
	<div class="clear"></div>

		</div>
		<div id="LessonPageNav">
		  <p></p>
		  <ul>
		    <li id="LessonPagePrevious"><a href="Getting_Started.html">Previous Page: Getting Started</a> &nbsp;</li>
		    <li id="LessonPageCount">Page <strong>3</strong> of <strong>5</strong></li>
		    <li id="LessonPageNext"><a href="Setting_up_for_user__roles_and_Resources_for_your_system.html">Next Page: Setting up for user, roles and Resources for your system</a> &nbsp;</li>
		    
		  </ul>
		</div>
	</div>	
</body>
</html>